<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>取得当前系统状态</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mysql-set-charset.html">mysql_set_charset</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mysql-tablename.html">mysql_tablename</a></div>
 <div class="up"><a href="ref.mysql.html">MySQL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.mysql-stat" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">mysql_stat</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">mysql_stat</span> &mdash; <span class="dc-title">取得当前系统状态</span></p>

   </div>
   <div class="refsect1 unknown-seealsp" id="refsect1-function.mysql-stat-unknown-seealsp">
    <h3 class="title">说明</h3>
    <div class="methodsynopsis dc-description">
     <span class="type">string</span> <span class="methodname"><strong>mysql_stat</strong></span>
      ([ <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link_identifier</code></span>
    ] )</div>

    <p class="para rdfs-comment">
     <span class="function"><strong>mysql_stat()</strong></span> 返回当前服务器状态。
    </p>
    <blockquote class="note"><p><strong class="note">Note</strong>: 
     <p class="para">
      <span class="function"><strong>mysql_stat()</strong></span>
      目前只返回
      uptime，threads，queries，open tables，flush tables 和 queries per
      second。要得到其它状态变量的完整列表，只能使用 SQL 命令
      SHOW STATUS。
     </p>
    </p></blockquote>
    <p class="para">
     <div class="example" id="example-1585">
      <p><strong>Example #1 <span class="function"><strong>mysql_stat()</strong></span> 例子</strong></p>
      <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$link&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"mysql_user"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"mysql_password"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$status&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">explode</span><span style="color: #007700">(</span><span style="color: #DD0000">'&nbsp;&nbsp;'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">mysql_stat</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$status</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
      </div>

      <div class="example-contents"><p>
       以上例子将产生如下输出：
      </p></div>
      <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [0] =&gt; Uptime: 5380
    [1] =&gt; Threads: 2
    [2] =&gt; Questions: 1321299
    [3] =&gt; Slow queries: 0
    [4] =&gt; Opens: 26
    [5] =&gt; Flush tables: 1
    [6] =&gt; Open tables: 17
    [7] =&gt; Queries per second avg: 245.595
)
</pre></div>
      </div>
     </div>
    </p>
   </div>

  </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mysql-set-charset.html">mysql_set_charset</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mysql-tablename.html">mysql_tablename</a></div>
 <div class="up"><a href="ref.mysql.html">MySQL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
